<script setup lang="ts">
import { getBannerAPI } from '@/apis/home';
import { BannerType } from '@/types/banner';
import { onMounted, ref } from 'vue';

// 获取轮播图的方法
const bannerList = ref<Array<BannerType>>([]);
const getBanner = async () => {
    const response = await getBannerAPI({ distributionSite: '2' });
    bannerList.value = response.data.result;
};

// 自动获取轮播图
onMounted(() => getBanner());
</script>

<template>
    <div class="home-banner">
        <el-carousel height="500px">
            <el-carousel-item v-for="item in bannerList" :key="item">
                <img :src="item.imgUrl" alt="">
            </el-carousel-item>
        </el-carousel>
    </div>
</template>

<style scoped lang='scss'>
.home-banner {
    margin: 0 auto;
    width: 1240px;
    height: 500px;
    left: 0;
    top: 0;
    z-index: 98;

    img {
        width: 100%;
        height: 500px;
    }
}
</style>